package com.cy.pj.notice.dao.impl;

import com.cy.pj.notice.dao.NoticeJdbcTemplateDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.sql.DataSource;

@Repository
public class NoticeJdbcTemplateDaoImpl implements NoticeJdbcTemplateDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;//spring为其进行set注入的时候，需要datesource

    public NoticeJdbcTemplateDaoImpl(DataSource dataSource){

        this.jdbcTemplate = new JdbcTemplate(dataSource);
    }

    public void updateNotice(String sql,Object[] values){
        jdbcTemplate.update(sql, values);
        System.out.println("insert ok");
    }

    @Override
    public void selectNotice(String sql) {
        jdbcTemplate.queryForList(sql);
    }


}
